<script type="text/javascript" language="javascript" charset="utf-8">
$(".header-con li a").removeClass("open-menu");
$(".header-con li #configuration").addClass("open-menu");
</script>
<div class="boxed clearfix">
  <div class="common-tit">
    <h2>商品设置</h2>
    <span>公司设置 > 商品设置</span>
  </div>
  <div class="ad-box">
    <div class="account-infor">
      <%= render partial: "company_configuration_nav" %>
      <h3>
        <span>部门设置</span>
      </h3>
      <div class="comp-set">
        <ul class="commod">
          <% @default_departments.each do |department| %>
            <li>
              <span>工作室部门:</span>
              <em><%= department.department_name %></em>
            </li>
          <% end %>
        </ul>
        <% @private_departments.each do |department| %>
          <div class="com-stuw clearfix">
            <ul class="com-stwcon">
              <li>
                <span>工作室部门:</span>
                <em><%= department.department_name %></em>
              </li>
            </ul>
            <div>
              <%= link_to '删除','javascript:void(0)',
                onclick: "ajax_function('/admin/company_configurations/destroy_configuration', 'department', 'DepartmentConfiguration', #{department.id})",
                id: "delete_department#{department.id}", class: "comm-del" %>
          </div>
          </div>
        <% end %>
        <%= form_for(@department, url: create_department_admin_company_configurations_path, html: { multipart: true}) do |f| %>
          <div class="com-stua cstua clearfix">
            <ul class="com-stcon">
              <li>
                <span>工作室部门:</span>
                <%= f.text_field :department_name %>
              </li>
            </ul>
            <%= f.submit "添加", class: "comm-add" %>
          </div>
        <% end %>
      </div>
      <h3>
        <span>职位设置</span>
      </h3>
      <div class="comp-setbox">
        <div class="comp-set">
          <ul class="commod">
            <% @default_positions.each do |position| %>
              <li>
                <span>职位名称:</span>
                <em><%= position.position_name %></em>
              </li>
            <% end %>
          </ul>
          <% @private_positions.each do |position| %>
            <div class="com-stuw clearfix">
              <ul class="com-stwcon">
                <li>
                  <span>职位名称:</span>
                  <em><%= position.position_name %></em>
                </li>
              </ul>
              <div>
                <%= link_to '删除','javascript:void(0)',
                  onclick: "ajax_function('/admin/company_configurations/destroy_configuration', 'position', 'PositionConfiguration', #{position.id})",
                  id: "delete_position#{position.id}", class: "comm-del" %>
            </div>
            </div>
          <% end %>
          <%= form_for(@position, url: create_position_admin_company_configurations_path, html: { multipart: true}) do |f| %>
            <div class="com-stua cstua clearfix">
              <ul class="com-stcon">
                <li>
                  <span>职位名称:</span>
                  <%= f.text_field :position_name %>
                </li>
              </ul>
              <%= f.submit "添加", class: "comm-add" %>
            </div>
          <% end %>
        </div>
      </div>
      <h3>
        <span>导师等级</span>
      </h3>
      <div class="comp-setbox">
        <div class="comp-set">
          <% @teacher_levels.each do |teacher_level| %>
            <div class="com-stuw clearfix">
              <ul class="com-stwcon">
                <li>
                  <span>导师等级:</span>
                  <em><%= teacher_level.teacher_level %></em>
                </li>
              </ul>
              <div>
                <%= link_to '删除','javascript:void(0)',
                  onclick: "ajax_function('/admin/company_configurations/destroy_configuration', 'teacher_level', 'TeacherLevelConfiguration', #{teacher_level.id})",
                  id: "delete_teacher_level#{teacher_level.id}", class: "comm-del" %>
            </div>
            </div>
          <% end %>
          <%= form_for(@teacher_level, url: create_teacher_level_admin_company_configurations_path, html: { multipart: true}) do |f| %>
            <div class="com-stua cstua clearfix">
              <ul class="com-stcon">
                <li>
                  <span>导师等级:</span>
                  <%= f.text_field :teacher_level %>
                </li>
              </ul>
              <%= f.submit "添加", class: "comm-add" %>
            </div>
          <% end %>
        </div>
      </div>
      <h3>
        <span>员工福利设置</span>
      </h3>
      <div class="comp-setbox">
        <div class="comp-set">
          <% @employee_welfares.each do |welfare| %>
            <div class="hrw-welfare clearfix">
              <ul class="hrw-con">
                <li>
                  <span>福利名称:</span>
                  <em><%= welfare.welfare_name %></em>
                </li>
                <li>
                  <span>福利金额:</span>
                  <em><%= welfare.amount %>元/月</em>
                </li>
              </ul>
              <div>
                <%= link_to '删除','javascript:void(0)',
                  onclick: "ajax_function('/admin/company_configurations/destroy_configuration', 'employee_welfare', 'EmployeeWelfareConfiguration', #{welfare.id})",
                  id: "delete_employee_welfare#{welfare.id}", class: "comm-del" %>
            </div>
            </div>
          <% end %>
          <%= form_for(@employee_welfare,:url => create_employee_welfare_admin_company_configurations_path,  html: { multipart: true}) do |f| %>
            <div class="hra-welfare clearfix">
              <ul class="hra-stcon">
                <li>
                  <span>福利名称:</span>
                  <%= f.text_field :welfare_name %>
                </li>
                <li>
                  <span>福利金额:</span>
                  <%= f.text_field :amount %>
                  <span>元/月</span>
                </li>
              </ul>
              <%= f.submit "添加", class: "comm-add" %>
            </div>
          <% end %>
        </div>
      </div>
    </div>
    <!-- <div class="com-sbtn">保存</div> -->
  </div>
</div>
<script src="/assets/js/common-list.js"></script>

<script>
//删除人资设置
ajax_function = function (url, type, model_name, value){
  var id="#delete_" +type +value
    if (confirm("确认删除吗？")){
      $.ajax({
        url: url,
        type:'DELETE',
        data: {
          model_name: model_name,
          value: value,
        },
        success: function(data){
          $(id).parent().parent().remove();
        },
        error:function(){
          alert("出错");
        }
      });
    }
}
</script>
